grpc::Status {{ name.upper_camel_case }}(
    grpc::ServerContext* /* context */,
    const rpc::{{ plugin_name.lower_snake_case }}::{{ name.upper_camel_case }}Request* {% if not params -%} /* request */ {%- else -%} request {%- endif -%},
    rpc::{{ plugin_name.lower_snake_case }}::{{ name.upper_camel_case }}Response* response) override
{
    if (_lazy_plugin.maybe_plugin() == nullptr) {
        {% if has_result %}
        if (response != nullptr) {
            {% if is_server %}
            // For server plugins, this should never happen, they should always be constructible.
            auto result = mavsdk::{{ plugin_name.upper_camel_case }}::Result::Unknown;
            {% else -%}
            auto result = mavsdk::{{ plugin_name.upper_camel_case }}::Result::NoSystem;
            {% endif -%}
            fillResponseWithResult(response, result);
        }
        {% endif %}
        return grpc::Status::OK;
    }

    {% if params -%}
    if (request == nullptr) {
        LogWarn() << "{{ name.upper_camel_case }} sent with a null request! Ignoring...";
        return grpc::Status::OK;
    }
    {%- endif %}

    auto result = _lazy_plugin.maybe_plugin()->{{ name.lower_snake_case }}({% for param in params %}{% if not param.type_info.is_primitive %}translateFromRpc{{ param.name.upper_camel_case }}({% endif %}request->{{ param.name.lower_snake_case }}(){% if not param.type_info.is_primitive %}){% endif %}{{ ", " if not loop.last }}{% endfor %});

    if (response != nullptr) {
        {% if has_result %}fillResponseWithResult(response, result.first);{% endif %}
        {% if return_type.is_repeated %}
        for (auto elem : result.second) {
            {% if return_type.is_primitive %}
            response->add_{{ return_name.lower_snake_case }}(elem);
            {% else %}
            auto* ptr = response->add_{{ return_name.lower_snake_case }}();
            ptr->CopyFrom(*translateToRpc{{ return_type.inner_name }}(elem).release());
            {% endif %}
        }
        {% else %}
        response->set_{% if return_type.is_primitive %}{{ return_name.lower_snake_case }}(result{% if has_result %}.second{% endif %}{% elif return_type.is_enum %}{{ return_name.lower_snake_case }}(translateToRpc{{ return_type.inner_name }}(result{% if has_result %}.second{% endif %}){% else %}allocated_{{ return_name.lower_snake_case }}(translateToRpc{{ return_type.inner_name }}(result{% if has_result %}.second{% endif %} ).release(){% endif %});
        {% endif %} }


    return grpc::Status::OK;
}
